<?php
include("../lib/config.php");

if($_GET['tipe'] == 'jenjang') {
	$sql = "SELECT * FROM fakultas WHERE jenjang_id = ".$_GET['id']."";
} elseif($_GET['tipe'] == 'fakultas') {
	$sql = "SELECT * FROM jurusan WHERE fakultas_id = ".$_GET['id']."";
} else {
	die('Wrong parameter');
}

$query = mssql_query($sql, $conn);


$result = array();
$i = 0;
while($temp = mssql_fetch_array($query)) {
	$result[$i]['id'] = $temp['id'];
	$result[$i]['nama'] = $temp['nama'];
	$i++;
}


$json = json_encode($result);

header("Pragma: no-cache");
header("Cache-Control: no-store, no-cache, max-age=0, must-revalidate");
header('Content-Type: application/json');
header("X-JSON: ".$json);

echo $json;
?>